package com.example;


import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.oauth2.provider.OAuth2Authentication;

public class UserUtil {

	/**
	 * 获取登陆的 LoginAppUser
	 * 
	 * @return
	 */
	@SuppressWarnings("rawtypes")
	public static Object getLoginAppUser() {
		Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
		System.err.println(authentication.getClass().getSimpleName());
		if (authentication instanceof OAuth2Authentication) {
			OAuth2Authentication oAuth2Auth = (OAuth2Authentication) authentication;
			return oAuth2Auth.getUserAuthentication().getDetails();
		}

		return null;
	}
}
